#!/bin/sh
#指定部署目录，拉取git上最新的代码
codePath="/home/liangmx/lmx-server/lmx-server"
homePath="/home/liangmx"
shellPath="/home/liangmx/lmx-server/lmx-server/deploy/shell"
target_path="/home/liangmx/lmx-server/lmx-server/target"
publish_path="/home/liangmx/lmx-server/lmx-server/dev-publish"
gitOsc="git@git.oschina.net:huibati/tiannainbao.git"
package_path="/home/liangmx/lmx-server/lmx-server/src/main/resources/"
test_lib_path="/home/liangmx/lmx-server/lmx-server/deploy/env/test/"
product_lib_path="/home/liangmx/lmx-server/lmx-server/deploy/env/product/"
application="application.properties"
log4j="log4j.properties"
persistence_mysql="persistence-mysql.properties"
jar_name="tnb-server_test.jar"

publish_lib_path="/home/liangmx/lmx-server/lmx-server/deploy/env/product/"
#################################GIT拉取最新代码##################################
echo  "拉取代码..."
cd $homePath
if [ ! -d $codePath ]
then
	rm -rf $codePath
	git clone $gitOsc
	git branch product --track origin/product
else
    echo  "拉取代码...1"
	cd $codePath
fi
###################################################################################

#################################选择打包库########################################
echo  "请选择打包库："
read -p  "测试库（1）  发布测试库（2）  退出（3）" choic

if [ $choic -eq 1 ]
then
	echo "打包 测试库"
	echo "拉取代码"
	git checkout master
	git pull
	cp $test_lib_path$application $package_path$application
	cp $test_lib_path$log4j $package_path$log4j
	cp $test_lib_path$persistence_mysql $package_path$persistence_mysql
	source $shellPath/ssh_deploy-23_back_end.sh
elif [ $choic -eq 2 ]
then
	echo "打包发布测试库"
	echo "拉取代码"
	git checkout master
	git pull
	publish_path="/home/liangmx/lmx-server/lmx-server/test-publish"
	jar_name="tnb-server_test.jar"
	echo "publish_path is:"$publish_path
	cp $publish_lib_path$application $package_path$application
	cp $publish_lib_path$log4j $package_path$log4j
	cp $publish_lib_path$persistence_mysql $package_path$persistence_mysql
	source $shellPath/ssh_deploy-23_back_end.sh
elif [ $choic -eq 3 ]
then
	exit 0
else
	exit 2
fi
###################################################################################
echo  "ok..."